增加过程日志

chengzhenyu 6 anni fa
parent
commit
b8db06493d

+ 8 - 2
app/src/main/java/ai/pai/ptp/test/MyTestActivity.java

@@ -26,8 +26,6 @@ public class MyTestActivity extends Activity implements Camera.CameraListener {
26 26
 
27 27
     private final String TAG = MyTestActivity.class.getSimpleName();
28 28
 
29
-    private final Handler handler = new Handler();
30
-
31 29
     private PtpService ptp;
32 30
     private Camera camera;
33 31
     private boolean isInStart;
@@ -89,11 +87,13 @@ public class MyTestActivity extends Activity implements Camera.CameraListener {
89 87
     @Override
90 88
     public void onCameraStarted(Camera camera) {
91 89
         this.camera = camera;
90
+        adapter.addInfo("开始会话");
92 91
     }
93 92
 
94 93
     @Override
95 94
     public void onCameraStopped(Camera camera) {
96 95
         this.camera = null;
96
+        adapter.addInfo("结束会话");
97 97
     }
98 98
 
99 99
     @Override
@@ -174,6 +174,7 @@ public class MyTestActivity extends Activity implements Camera.CameraListener {
174 174
 
175 175
     @Override
176 176
     public void onObjectAdded(int handle, int format) {
177
+        adapter.addInfo("相机系统发现新文件 ,文件句柄 ="+ handle + " format = "+ format);
177 178
         if (camera == null) {
178 179
             return;
179 180
         }
@@ -181,4 +182,9 @@ public class MyTestActivity extends Activity implements Camera.CameraListener {
181 182
             camera.retrievePicture(handle);
182 183
         }
183 184
     }
185
+
186
+    @Override
187
+    public void onLogMessage(String msg) {
188
+        adapter.addInfo(msg);
189
+    }
184 190
 }

+ 2 - 0
app/src/main/java/com/remoteyourcam/usb/ptp/Camera.java

@@ -89,6 +89,8 @@ public interface Camera {
89 89
         void onFocusPointsChanged();
90 90
 
91 91
         void onObjectAdded(int handle, int format);
92
+
93
+        void onLogMessage(String msg);
92 94
     }
93 95
 
94 96
     // callbacks aren't on UI thread

+ 6 - 0
app/src/main/java/com/remoteyourcam/usb/ptp/PtpUsbService.java

@@ -88,6 +88,7 @@ public class PtpUsbService implements PtpService {
88 88
         if (camera != null) {
89 89
             if (AppConfig.LOG) {
90 90
                 Log.i(TAG, "initialize: camera available");
91
+                listener.onLogMessage("有可用相机,初始化中");
91 92
             }
92 93
             if (camera.getState() == State.Active) {
93 94
                 if (listener != null) {
@@ -104,14 +105,17 @@ public class PtpUsbService implements PtpService {
104 105
         if (device != null) {
105 106
             if (AppConfig.LOG) {
106 107
                 Log.i(TAG, "initialize: got device through intent");
108
+                listener.onLogMessage("发现可用相机设备"+device.getDeviceName());
107 109
             }
108 110
             connect(context, device);
109 111
         } else {
110 112
             if (AppConfig.LOG) {
111 113
                 Log.i(TAG, "initialize: looking for compatible camera");
114
+                listener.onLogMessage("查找相机设备...");
112 115
             }
113 116
             device = lookupCompatibleDevice(usbManager);
114 117
             if (device != null) {
118
+                listener.onLogMessage("查找到相机设备"+device.getDeviceName());
115 119
                 registerPermissionReceiver(context);
116 120
                 PendingIntent mPermissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(
117 121
                         ACTION_USB_PERMISSION), 0);
@@ -126,6 +130,7 @@ public class PtpUsbService implements PtpService {
126 130
     public void shutdown() {
127 131
         if (AppConfig.LOG) {
128 132
             Log.i(TAG, "shutdown");
133
+            listener.onLogMessage("关闭设备");
129 134
         }
130 135
         if (camera != null) {
131 136
             camera.shutdown();
@@ -204,6 +209,7 @@ public class PtpUsbService implements PtpService {
204 209
                 Log.i(TAG, "Interface protocol " + intf.getInterfaceProtocol());
205 210
                 Log.i(TAG, "Bulk out max size " + out.getMaxPacketSize());
206 211
                 Log.i(TAG, "Bulk in max size " + in.getMaxPacketSize());
212
+                listener.onLogMessage("发现兼容的USB接口设备 "+ device.getDeviceName() +" "+  device.getVendorId());
207 213
             }
208 214
 
209 215
             if (device.getVendorId() == PtpConstants.CanonVendorId) {